package com.chance.cc.crawler.development.bootstrap.bitauto.dealer;

import com.chance.cc.crawler.core.CrawlerEnum;
import com.chance.cc.crawler.core.filter.FilterUtils;
import com.chance.cc.crawler.core.record.CrawlerRequestRecord;
import com.chance.cc.crawler.development.controller.DevCrawlerController;
import org.junit.Test;

/**
 * @ClassName song
 * @Description TODO
 * @Author ding
 * @Date 2021/9/12 12:54
 * @Version 1.0
 * 易车经销商
 **/
public class BitAutoDealerStart {
    public static void main(String[] args) {
        gatherSeries();
    }

    /*
     * 爱卡车型车系采集
     * */
    private static final String domain = "bitauto";
    private static final String side = "bitAutoDealer";
    public static void gatherSeries() {
      //  String url = "https://dealer.yiche.com/";//爱卡汽车网
       // String url = "https://dealer.yiche.com/shandong/bmw/";
        String url = "https://dealer.yiche.com/zhejiang/bmw/";
        CrawlerRequestRecord record = CrawlerRequestRecord.builder()
                .startPageRequest(domain, CrawlerEnum.CrawlerRequestType.turnPage)
                .httpUrl(url)
                .domain(domain)
                .filter(CrawlerEnum.CrawlerRecordFilter.keyOrDateRange)
                .addFilterInfo(FilterUtils.memoryFilterKeyInfo(domain))
                .addFilterInfo(FilterUtils.dateRangeFilterInfo(24 * 30, null))
                .resultLabelTag(CrawlerEnum.CrawlerDataType.article)
                .resultLabelTag(CrawlerEnum.CrawlerDataType.interaction)
                .resultLabelTag(CrawlerEnum.CrawlerDataType.comment)
                .build();
        record.setNeedWashPage(true);
        record.setSkipPipeline(true);
        record.setDownload(false);
        record.tagsCreator().bizTags().addSite(side);
        record.tagsCreator().bizTags().addSiteBiz(side);
        record.tagsCreator().bizTags().addDomain(domain);


        CrawlerRequestRecord keywordRecord = CrawlerRequestRecord.builder()
                .startPageRequest(domain, CrawlerEnum.CrawlerRequestType.turnPageItem)
                .httpUrl("http://192.168.1.215:9599/v1/meta/bitauto/keys?site=bitCitySeries")
                .requestLabelTag(CrawlerEnum.CrawlerRequestType.supportSource)
                .requestLabelTag(CrawlerEnum.CrawlerRequestType.internalDownload)
                .build();


        DevCrawlerController.builder()
                .triggerInfo(domain, domain, System.currentTimeMillis(), domain)
                .crawlerThreadNum(30)
                .crawlerRequestQueue(DevCrawlerController.devRequestQueue(domain))
                .consoleResultPipeline("kafka")
                .fileResultPipeline("kafka", "F:\\chance_log\\bitauto\\carType\\dealer.log", false)
                .requestRecord(record)
                .supportRecord(keywordRecord)
                .build("com.chance.cc.crawler.development.scripts.bitauto")
                .start();
    }
    @Test
    public void s(){
        String s = "\"{\"北京\":[\"宝马\",\"奔驰\",\"奥迪\",\"雷克萨斯\",\"林肯\",\"沃尔沃\",\"保时捷\",\"玛莎拉蒂\",\"凯迪拉克\",\"捷豹\",\"路虎\",\"英菲尼迪\"]}\"";
        s.replaceAll("","");
        System.out.println(s);
    }
}
